package com.frx.leetoffer.dayone;


import java.util.Stack;

/**
 * Created with IDEA
 * @description 用两个栈来模拟队列
 * @author: xrf
 * @Date: 2019/5/9
 * @Time: 17:45
 */
public class StackQueue {

    Stack<Integer> in = new Stack<>();
    Stack<Integer> out = new Stack<>();


    public void push(int node){
        in.push(node);
    }

    public Integer pop() {
        if (out.isEmpty()){
            while (!in.isEmpty()){
                out.push(in.pop());
            }
        }

        return out.pop();
    }
    public static void main(String[] args){
        StackQueue stackQueue = new StackQueue();
        stackQueue.push(1);
        stackQueue.push(2);
        stackQueue.push(3);
        stackQueue.push(4);
        System.out.println(stackQueue.pop());
    }

}
